﻿package mortal.game.view.lotteryDraw
{
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class LotteryExchangeCategorySpr extends GSprite
    {
        private var _tagList:GTileList;

        public function LotteryExchangeCategorySpr()
        {
            return;
        }// end function

        public function switchTag(param1:int) : void
        {
            this._tagList.selectedIndex = param1;
            this.onItemChange();
            return;
        }// end function

        private function onItemChange(event:Event = null) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.LotteryExchangeSwitchPanel, this._tagList.selectedIndex));
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.bg(0, 0, 648, 42, this, ImagesConst.ShopGroupTabBg));
            this._tagList = UIFactory.tileList(17, 0, 500, 42, this);
            this._tagList.columnWidth = 100;
            this._tagList.rowHeight = 42;
            this._tagList.horizontalGap = 1;
            this._tagList.verticalGap = 4;
            this._tagList.setStyle("cellRenderer", lotteryExchangeCategoryCellRender);
            this._tagList.dataProvider = this.getTagListDataProvider();
            this._tagList.direction = GBoxDirection.HORIZONTAL;
            this._tagList.drawNow();
            this._tagList.configEventListener(Event.CHANGE, this.onItemChange);
            return;
        }// end function

        private function getTagListDataProvider() : DataProvider
        {
            var _loc_3:int = 0;
            var _loc_5:LotteryExchangeCategoryData = null;
            var _loc_7:LotteryExchangeCategoryData = null;
            var _loc_1:* = new DataProvider();
            var _loc_2:* = Cache.instance.role.entityInfo.level;
            var _loc_4:* = LotteryExchangeConst.exchangeDataArr;
            var _loc_6:int = 0;
            while (_loc_6 < _loc_4.length)
            {
                
                _loc_7 = _loc_4[_loc_6];
                _loc_3 = _loc_7.level;
                if (_loc_2 >= _loc_3)
                {
                    _loc_1.addItem(_loc_7);
                }
                _loc_6++;
            }
            return _loc_1;
        }// end function

        public function get dataProvider() : DataProvider
        {
            return this._tagList.dataProvider;
        }// end function

        public function get selectItemData() : LotteryExchangeCategoryData
        {
            return this._tagList.selectedItem as LotteryExchangeCategoryData;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._tagList.dispose(param1);
            this._tagList = null;
            super.disposeImpl(param1);
            return;
        }// end function

    }
}
